home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d16 / rtf.arc / RTF.TXT < prev   
Text File  |  1991-08-17  |  14KB  |  643 lines

  1. Specification for RTF
  2.  
  3. ---------------------
  4.  
  5. RTF text is a form of encoding of various text
  6.  
  7. formatting properties, document structures,
  8.  
  9. and document properties, using the printable 
  10.  
  11. ASCII character set. Special characters can be also
  12.  
  13. thus encoded, although RTF does not prevent the utilization
  14.  
  15. of character codes outside the ASCII printable set.
  16.  
  17. The main encoding mechanism of "control words" provides a name
  18.  
  19. space that may be later used to expand the realm of RTF with
  20.  
  21. macros, programming, etc.
  22.  
  23. 1. BASIC INGREDIENTS
  24.  
  25. Control words are of the form:
  26.  
  27. \lettersequence <delimiter> where <delimiter>. is:
  28.  
  29. . a space: the space is part of the control word.
  30.  
  31. . a digit or - means that a parameter follows. The following
  32. digit
  33.  
  34. sequence is then delimited by a space or any other
  35.  
  36. non-letter-or-digit as for control words.
  37.  
  38. . any other non-letter-or digit: terminates the control word,
  39. but is not
  40.  
  41. a part of the control word.
  42.  
  43. By "letter:, here we mean just the upper and lower case ASCII
  44. letters.
  45.  
  46. Control symbols consist of a \ character followed by a single
  47.  
  48. non-letter. They require no further delimiting.
  49.  
  50. Notes: control symbols are compact, but there are not too many
  51.  
  52. of them. The number of possible control words are not limited.
  53.  
  54. The parameter is partially incorporated in control symbols, so
  55. that
  56.  
  57. a program that does not understand a control symbol can recognize
  58.  
  59. and ignore the corresponding parameter as well.
  60.  
  61. In addition to control words and control symbols, there are also
  62. the braces:
  63.  
  64. {       group start, and
  65.  
  66. }       group end. The text grouping will be used for formatting
  67.  
  68. and to delineate document structure - such as the footnotes,
  69. headers,
  70.  
  71. title, and so on. The control words, control symbols, and braces
  72.  
  73. constitute control information. All other characters in RTF text
  74.  
  75. constitute "plain text".
  76.  
  77. Since the characters \, {, and } have specific uses in RTF,
  78.  
  79. the control symbols \\,\{, and \} are provided to express
  80.  
  81. the corresponding plain characters.
  82.  
  83. 2. WHAT RTF TEXT MEANS (SEMANTICS)
  84.  
  85. The reader of a RTF stream will be concerned with:
  86.  
  87. Separating control information from plain text.
  88.  
  89. Acting on control information. This is designed to be
  90.  
  91. a relatively simple process, as described below.
  92.  
  93. Some control information just contributes special
  94.  
  95. characters to the plain text stream.  Other information
  96.  
  97. serves to change the "program state" which includes
  98.  
  99. properties of the document as a whole and also a stack
  100.  
  101. of "group states" that apply to parts.
  102.  
  103. Note that the group state is saved by the { brace and is
  104.  
  105. restored by the } brace. The current group state specifies:
  106.  
  107. 1. the "destination" or part of the document that the
  108.  
  109. plain text is building up.
  110.  
  111. 2. the character formatting properties - such as bold or
  112.  
  113. italic.
  114.  
  115. 3. the paragraph formatting properties - such as justified.
  116.  
  117. 4. the section formatting properties - such as number of columns.
  118.  
  119. Collecting and properly disposing of the remaining "plain text"
  120.  
  121. as directed by the current group state.
  122.  
  123. In practice the RTF reader will proceed as follows:
  124.  
  125. 0. read next char
  126.  
  127. 1. if ={
  128.  
  129. stack current state. current state does not change.
  130.  
  131. continue.
  132.  
  133. 2. if =}
  134.  
  135. unstack current state from stack. this will change the
  136.  
  137. state in general.
  138.  
  139. 3. if =\
  140.  
  141. collect control word/control symbol and parameter, if any.
  142.  
  143. look up word/symbol in symbol table (a constant table)
  144.  
  145. and act according to the description there. The different
  146.  
  147. actions are listed below. Parameter is left available for use by
  148. the action.
  149.  
  150. Leave read pointer before or after the delimiter, as appropriate.
  151.  
  152. After the action, continue.
  153.  
  154. 4. otherwise, write "plain text" character to current destination
  155.  
  156. using current formatting properties.
  157.  
  158. Given a symbol table entry, the possible actions are as follows:
  159.  
  160. A. Change destination:
  161.  
  162. change destination to the destination described in the entry.
  163.  
  164. Most destination changes are legal only immediately after a {.
  165.  
  166. Other restrictions may also apply (for example, footnotes 
  167.  
  168. may not be nested.)
  169.  
  170. B. Change formatting property:
  171.  
  172. The symbol table entry will describe the property and
  173.  
  174. whether the parameter is required.
  175.  
  176. C. Special character:
  177.  
  178. The symbol table entry will describe the character code..
  179.  
  180. goto 4.
  181.  
  182. D. End of paragraph
  183.  
  184. This could be viewed as just a special character.
  185.  
  186. E. End of section
  187.  
  188. This could be viewed as just a special character.
  189.  
  190. F. Ignore
  191.  
  192. 3. SPECIAL CHARACTERS
  193.  
  194. The special characters are explained as they exist in Mac Word.
  195.  
  196. Clearly, other characters may be added for interchange with other
  197.  
  198. programs. If a character name is not recognized by a reader,
  199. according
  200.  
  201. to the rules described above, it will be simply ignored.
  202.  
  203. \chpgn          current page number (as in headers)
  204.  
  205. \chftn          auto numbered footnote reference
  206.  
  207. (footnote to follow in a group)
  208.  
  209. \chpict         placeholder character for picture
  210.  
  211. (picture to follow in a group)
  212.  
  213. \chdate         current date (as in headers)
  214.  
  215. \chtime         current time (as in headers)
  216.  
  217. \|              formula character
  218.  
  219. \~              non-breaking space
  220.  
  221. \-              non-required hyphen
  222.  
  223. \_              non-breaking hyphen
  224.  
  225. \page           required page break
  226.  
  227. \line           required line break (no paragraph break)
  228.  
  229. \par            end of paragraph.
  230.  
  231. \sect           end of section and end of paragraph.
  232.  
  233. \tab            same as ASCII 9
  234.  
  235. For simplicity of operation, the ASCII codes 9 and 10 will be
  236. accepted
  237.  
  238. as \tab and \par respectively. ASCII 13 will be ignored. The
  239. control
  240.  
  241. code \<10> will be ignored. It may be used to include "soft"
  242. carriage
  243.  
  244. returns for easier readability but which will have no effect
  245.  
  246. on the interpretation.
  247.  
  248. 4. DESTINATIONS
  249.  
  250. The change of destination will reset all properties to default.
  251. Changes
  252.  
  253. are legal only at the beginning of a group (by group here we
  254. mean the
  255.  
  256. text and controls enclosed in braces.)
  257.  
  258. \rtf<param>
  259.  
  260. The destination is the document. The parameter is the
  261.  
  262. version number of the writer. This destination preceded
  263.  
  264. by { the beginnings of RTF documents and the corresponding }
  265.  
  266. marks the end.
  267.  
  268.  
  269.  
  270. Legal only once after the initial {. Small scale interchange of
  271. RTF where 
  272.  
  273. other methods for marking the end of string are available, as in
  274. a
  275.  
  276. string constant, need not include this identification but 
  277.  
  278. will start with this destination as the default.
  279.  
  280. \pict
  281.  
  282. The destination is a picture. The group must immediately
  283.  
  284. follow a \chpict character. The plain text describes
  285.  
  286. the picture as a hex dump (string of characters 0,1,...
  287.  
  288. 9, a, ..., e, f.)
  289.  
  290. (Formatting properties to determine data interpretation, size)
  291.  
  292. \footnote
  293.  
  294. The destination is a footnote text. The group must
  295.  
  296. immediately follow the footnote reference character(s).
  297.  
  298. \header
  299.  
  300. The destination is the header text for the current section.
  301.  
  302. The group must precede the first plain text character
  303.  
  304. in the section.
  305.  
  306. \headerl
  307.  
  308. Same as above, but header for left-hand pages.
  309.  
  310. \headerr
  311.  
  312. Same as above, but header for right-hand pages.
  313.  
  314. \headerf
  315.  
  316. Same as above, but header for first page.
  317.  
  318. \footer
  319.  
  320. Same as above, but footer.
  321.  
  322. \footerl
  323.  
  324. Same as above, but footer for left-hand pages.
  325.  
  326. \footerr
  327.  
  328. Same as above, but footer for right-hand pages.
  329.  
  330. \footerf
  331.  
  332. Same as above, but header for first page.
  333.  
  334. \ftnsep
  335.  
  336. Same as above, but text is footnote separator
  337.  
  338. \ftnsepc
  339.  
  340. Same as above, but text is separator for continued footnotes.
  341.  
  342. \ftncn
  343.  
  344. Same as above, but text is continued footnote notice.
  345.  
  346. \info
  347.  
  348. text is information block for the document. Parts of the
  349.  
  350. text is further classified by "properties" of the text
  351.  
  352. that are listed below - such as "title". These are not
  353.  
  354. formatting properties, but a device to delimit and identify
  355.  
  356. parts of the info from the text in the group.
  357.  
  358. \stylesheet
  359.  
  360. text is the style sheet for the document.
  361.  
  362. More precisely, text between semicolons are taken to be
  363.  
  364. style names which will be defined to stand for the
  365.  
  366. formatting properties which are in effect.
  367.  
  368. \fonttbl
  369.  
  370. font table. See below.
  371.  
  372. \colortbl
  373.  
  374. color table. See below.
  375.  
  376. \comment
  377.  
  378. text will be ignored.
  379.  
  380. 5. DOCUMENT FORMATTING PROPERTIES
  381.  
  382. (000 stands for a number which may be signed)
  383.  
  384. \paperw000      paper width in twips            12240
  385.  
  386. \paperh000      paper height                    15840
  387.  
  388. \margl000       left margin                     1800
  389.  
  390. \margr000       right margin                    1800
  391.  
  392. \margt000       top margin                      1440
  393.  
  394. \margb000       bottom margin                   1440
  395.  
  396. \facingp        facing pages
  397.  
  398. \gutter000      gutter width
  399.  
  400. \deftab000      default tab width               720
  401.  
  402. \widowctrl      enable widow control
  403.  
  404. \endnotes       footnotes at end of section
  405.  
  406. \ftnbj          footnotes at bottom of page     default
  407.  
  408. \ftntj          footnotes beneath text (top just)
  409.  
  410. \ftnstart000    starting footnote number        1
  411.  
  412. \ftnrestart     restart footnote numbers each page
  413.  
  414. \pgnstart000    starting page number            1
  415.  
  416. \linestart000   starting line number            1
  417.  
  418. \landscape      printed in landscape format
  419.  
  420. (the "next file" property will be encoded in the info text )
  421.  
  422. 6. SECTION FORMATTING PROPERTIES
  423.  
  424. \sectd          reset to default section properties
  425.  
  426. \nobreak        break code
  427.  
  428. \colbreak       break code                      default
  429.  
  430. \pagebreak      break code
  431.  
  432. \evenbreak      break code
  433.  
  434. \oddbreak       break code
  435.  
  436. \pgnrestart     restart page numbers at 1
  437.  
  438. \pgndec         page number format decimal      default
  439.  
  440. \pgnucrm        page number format uc roman
  441.  
  442. \pgnlcrm        page number format lc roman
  443.  
  444. \pgnucltr       page number format uc letter
  445.  
  446. \pgnlcltr       page number format lc letter
  447.  
  448. \pgnx000        auto page number x pos          720
  449.  
  450. \pgny000        auto page number y pos          720
  451.  
  452. \linemod000     line number modulus
  453.  
  454. \linex000       line number - text distance     360
  455.  
  456. \linerestart    line number restart at 1        default
  457.  
  458. \lineppage      line number restart on each page
  459.  
  460. \linecont       line number continued from prev section
  461.  
  462. \headery000     header y position from top of page      720
  463.  
  464. \footery000     footer y position from bottom of page   720
  465.  
  466. \cols000        number of columns               1
  467.  
  468. \colsx000       space between columns           720
  469.  
  470. \endnhere       include endnotes in this section
  471.  
  472. \titlepg        title page is special
  473.  
  474. 7. PARAGRAPH FORMATTING PROPERTIES
  475.  
  476. \pard           dreset to default para properties.
  477.  
  478. \s000           style
  479.  
  480. \ql             quad left                       default
  481.  
  482. \ql             right
  483.  
  484. \qj             justified
  485.  
  486. \qc             centered
  487.  
  488. \fi000          first line indent
  489.  
  490. \li000          left indent
  491.  
  492. \ri000          right indent
  493.  
  494. \sb000          space before
  495.  
  496. \sa000          space after
  497.  
  498. \sl000          space between lines
  499.  
  500. \keep           keep
  501.  
  502. \keepn          keep with next para
  503.  
  504. \sbys           side by side
  505.  
  506. \pagebb         page break before
  507.  
  508. \noline         no line numbering
  509.  
  510. \brdrt          border top
  511.  
  512. \brdrb          border bottom
  513.  
  514. \brdrl          border left
  515.  
  516. \brdrr          border right
  517.  
  518. \box            border all around
  519.  
  520. \brdrs          single thickness
  521.  
  522. \brdrth         thick
  523.  
  524. \brdrsh         shadow
  525.  
  526. \brdrdb         double
  527.  
  528. \tx000          tab position
  529.  
  530. \tqr            right flush tab (these apply to last specified
  531. pos)
  532.  
  533. \tqc            centered tab
  534.  
  535. \tqdec          decimal aligned tab
  536.  
  537. \tldot          leader dots
  538.  
  539. \tlhyph         leader hyphens
  540.  
  541. \tlul           leader underscore
  542.  
  543. \tlth           leader thick line
  544.  
  545. 8. CHARACTER FORMATTING PROPERTIES
  546.  
  547. \plain          reset to default text properties.
  548.  
  549. \b              bold
  550.  
  551. \i              italic
  552.  
  553. \strike         strikethrough
  554.  
  555. \outl           outline
  556.  
  557. \shad           shadow
  558.  
  559. \scaps          small caps
  560.  
  561. \caps           all caps
  562.  
  563. \v              invisible text
  564.  
  565. \f000           font number n
  566.  
  567. \fs000          font size in half points        24
  568.  
  569. \ul             underline
  570.  
  571. \ulw            word underline
  572.  
  573. \uld            dotted underline
  574.  
  575. \uldb           double underline
  576.  
  577. \up000          superscript in half points
  578.  
  579. \dn000          subscript in half points
  580.  
  581. 9. INFO GROUP
  582.  
  583. The plain text in the group is used to specify the various
  584. fields of the information block. The current field may be
  585. thought of as a particular setting of the "sub-destination"
  586. property of the text..
  587.  
  588. \title          following plain text is the title
  589.  
  590. \subject        following text is the subject
  591.  
  592. \operator
  593.  
  594. \author
  595.  
  596. \keywords
  597.  
  598. \doccomm        comments (not to be confused with \comment )
  599.  
  600. \version
  601.  
  602. \nextfile       following text is name of "next" file
  603.  
  604. The other properties assign their parameters directly to the
  605. info block.
  606.  
  607. \verno000       internal version number
  608.  
  609. \creatim        creation time follows
  610.  
  611. \yr000          year to be assigned to previously specified time
  612. field
  613.  
  614. \mo000
  615.  
  616. \dy000
  617.  
  618. \hr000
  619.  
  620. \min000
  621.  
  622. \sec000
  623.  
  624. \revtim         revision time follows
  625.  
  626. \printtim       print time follows
  627.  
  628. \buptim         backup time follows
  629.  
  630. \edmins00       editing minutes
  631.  
  632. \nofpages000
  633.  
  634. \nofwords000
  635.  
  636. \noofchars000
  637.  
  638. \id000          internal ID number
  639.  
  640.  
  641.  
  642. 
  643.